#!/bin/bash
# fileinfo.sh
#
# Outputs some info about the file processed

# Filename checking
if [ -z $1 ]; then
	echo "Usage: $0 <FILE_NAME>"
	exit 1
fi

# Check if file exists
if [ ! -f "$1" ]; then
	echo "File $1 does not exist!";
	exit $E_FILE
fi

# Prints something about the file
ls -l $1 | awk '{ print "Filename:    " $8 "\nPermissions: " $1 "\nfile size:   " $5 }'\
'{ print "Owner:       " $3 "\nGroup:       " $4 "\nUID:         "$5 }'\
'{ print "Modified:    " $6 " @ " $7 }'

# Additional file info
# NOTE the whatis database must be set up before running the script
# Execute /usr/bin/makewhatis as root to make it working
whatis `basename $1`

exit 0
